package firsttest;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class FirstMain {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("firsttest/Beans.xml");
        //ApplicationContext context = new FileSystemXmlApplicationContext("F:/Idea_workspace/SpringStudy/src/Beans.xml");
        //这里有三种构建容器的方式，还有一种是通过 web 来构建的
        //FirstBeanParent firstBeanParent1 = (FirstBeanParent) context.getBean("FirstBeanParent");
        //FirstBeanParent firstBean2 = (FirstBeanParent) context.getBean("FirstBeanParent");

        FirstBeanParentChild firstBeanParentChild1 = (FirstBeanParentChild) context.getBean("FirstBeanChild");

        //System.out.println(firstBeanParent1.getName());

        firstBeanParentChild1.say();
        System.out.println(firstBeanParentChild1.getName() + firstBeanParentChild1.getAge());

        ((AbstractApplicationContext)context).registerShutdownHook();
    }
}
